/*   
 * Copyright (c) 2010-2020 DMGIS Ltd. All Rights Reserved.   
 *   
 * This software is the confidential and proprietary information of   
 * DMGIS. You shall not disclose such Confidential Information   
 * and shall use it only in accordance with the terms of the agreements   
 * you entered into with DMGIS.   
 *   
 */
package com.example.qxfw.common.util;

/**
 * This class is used for 字符串操作类
 * 
 * @author dsq
 * @version 1.0, 2018年7月30日 上午10:07:33
 */
public class StringUtil1 {

	/**
	 * 判断字符串是否为null或者空
	 * 
	 * @param string
	 * @return
	 * @author dsq
	 * @date 2018年7月30日
	 */
	public static boolean IsNullOrEmpty(String string) {
		return (string == null || string.equals(""));
	}

	/**
	 * 将字符null转变成null对象
	 * 
	 * @param string
	 * @return
	 * @author dsq
	 * @date 2018年7月30日
	 */
	public static String ParseNull(String string) {
		if (string.toLowerCase().equals("null")) {
			return null;
		} else {
			return string;
		}
	}

	public static String trimEnd(String value, char suffix) {
		int len = value.length();
		int st = 0;
		while ((st < len) && value.charAt(len - 1) == suffix) {
			len--;
		}
		return value.substring(0, len);
	}

	public static String trimStart(String value, char prefix) {
		int len = value.length();
		int st = -1;
		while ((st < len) && value.charAt(st + 1) == prefix) {
			st++;
		}
		return value.substring(st+1, len);
	}
}
